package com.fanshuai2.niuke.linkedlist;

import java.util.Scanner;

public class LastKNode {
    public static void main(String[] args) {
        class Node {
            int data;
            Node next;
            public Node(int data) {
                this.data = data;
                this.next = next;
            }
        }

        Scanner in = new Scanner(System.in);

        while (in.hasNextInt()) {
            Node head = null;
            Node tail = null;

            int num = in.nextInt();
            for (int i = 0; i < num; i++) {
                int d = in.nextInt();
                Node node = new Node(d);
                if (i == 0) {
                    head = node;
                    tail = node;
                } else {
                    tail.next = node;
                    tail = node;
                }
            }
            int k = in.nextInt();
            Node kNode = head;
            for (int i = 1; i <= k - 1; i++) {
                kNode = kNode.next;
            }
            Node pre = head;
            while (kNode.next != null) {
                pre = pre.next;
                kNode = kNode.next;
            }

            System.out.println(pre.data);
        }
    }
}
